<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>选择按钮事件处理示例</title>
    <style>
        /* 添加一些基本样式，使下拉选择按钮看起来更好看 */
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
        }

        select {
            padding: 10px;
            font-size: 16px;
            cursor: pointer;
            outline: none;
        }

        option {
            font-size: 16px;
        }

        img {
            max-width: 100%;
            height: auto;
            display: block;
            margin-top: 20px;
        }
    </style>
</head>

<body>
    <div>
        <!-- <button>选择</button> -->
        <label for="choices">请选择：</label>
        <select id="choices" onchange="choose_deal()">
            <option value="yes">是</option>
            <option value="no">否</option>
        </select>
    </div>

    <div id="imageContainer">
        <!-- 这里将显示渲染的图片 -->
    </div>

    <script>
        function choose_deal() {
            var choose1 = document.getElementById("choices");
            var imageContainer = document.getElementById("imageContainer");

            // 清空图片容器
            imageContainer.innerHTML = "";

            if (choose1.value === 'yes') {
                // 如果选择了是，渲染第一张图片
                var image1 = document.createElement("img");
                image1.src = "haha.png";
                imageContainer.appendChild(image1);
                console.log('是');
            } else if (choose1.value === 'no') {
                // 如果选择了否，渲染第二张图片
                var image2 = document.createElement("img");
                image2.src = "giao1.webp";
                imageContainer.appendChild(image2);
                console.log('否');
            }
        }
    </script>
</body>

</html>